package com.swsc.solarverse.dao.mapper;

import com.swsc.solarverse.dao.entity.forward.ForwardCombinerBoxDataDO;
import com.swsc.solarverse.dao.entity.forward.ForwardEnvironmentalMonitorDataDO;
import com.swsc.solarverse.dao.entity.forward.ForwardInverterDataDO;
import com.swsc.solarverse.dao.entity.forward.ForwardStringDataDO;

/**
 * @Author chencl
 * @Date 2024/6/4 12:51
 * @Version 1.0
 * @Description 自定义sql Mapper
 */
@org.apache.ibatis.annotations.Mapper
public interface CustomSqlMapper {
    /**
     * 批量插入环境监测仪历史数据
     * @param list
     * @return
     */
    @org.apache.ibatis.annotations.Insert(value = {
            "<script>",
            "INSERT IGNORE INTO solar_forward_environmental_monitor_data_his (`id`, `tenant_no`, `organ_no`, `device_id`, `device_name`, `wind_speed`, `temperature`, `total_radiation_1`, `acc_total_radiation_1`, `total_radiation_2`, `acc_total_radiation_2`, `scattered_radiation`, `acc_scattered_radiation`, `direct_radiation`, `acc_direct_radiation`, `data_time`, `create_time`) VALUES ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.id}, #{item.tenantNo}, #{item.organNo}, #{item.deviceId}, #{item.deviceName}, #{item.windSpeed}, #{item.temperature}, #{item.totalRadiation1}, #{item.accTotalRadiation1}, #{item.totalRadiation2}, #{item.accTotalRadiation2}, #{item.scatteredRadiation}, #{item.accScatteredRadiation}, #{item.directRadiation}, #{item.accDirectRadiation},  #{item.dataTime}, #{item.createTime})",
            "</foreach>",
            "</script>"
    })
    int insertIgnoreBatchEnvironmentMonitorDataHis(java.util.List<ForwardEnvironmentalMonitorDataDO> list);

    /**
     * 批量插入逆变器历史数据
     * @param list
     * @return
     */
    @org.apache.ibatis.annotations.Insert(value = {
            "<script>",
            "INSERT IGNORE INTO solar_forward_inverter_data_his_${tableSuffix} (`id`, `tenant_no`, `organ_no`, `device_id`, `device_name`, `voltage`, `electric_current`, `pv_input_power`, `power_generation`, `total_output`, `data_time`, `create_time`) VALUES ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.id}, #{item.tenantNo}, #{item.organNo}, #{item.deviceId}, #{item.deviceName}, #{item.voltage}, #{item.electricCurrent}, #{item.pvInputPower}, #{item.powerGeneration}, #{item.totalOutput},  #{item.dataTime}, #{item.createTime})",
            "</foreach>",
            "</script>"
    })
    int insertIgnoreBatchInverterDataHis(@org.apache.ibatis.annotations.Param("tableSuffix") String tableSuffix,
                                         @org.apache.ibatis.annotations.Param("list") java.util.List<ForwardInverterDataDO> list);
    /**
     * 批量插入汇流箱历史数据
     * @param list
     * @return
     */
    @org.apache.ibatis.annotations.Insert(value = {
            "<script>",
            "INSERT IGNORE INTO solar_forward_combiner_box_data_his_${tableSuffix} (`id`, `tenant_no`, `organ_no`, `device_id`, `device_name`, `total_voltage`, `i1`, `i2`, `i3`, `i4`, `i5`, `i6`, `i7`, `i8`, `i9`, `i10`, `i11`, `i12`, `i13`, `i14`, `i15`, `i16`, `data_time`, `create_time`) VALUES ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.id}, #{item.tenantNo}, #{item.organNo}, #{item.deviceId}, #{item.deviceName}, #{item.totalVoltage}, #{item.i1}, #{item.i2}, #{item.i3}, #{item.i4}, #{item.i5}, #{item.i6}, #{item.i7}, #{item.i8}, #{item.i9}, #{item.i10}, #{item.i11}, #{item.i12}, #{item.i13}, #{item.i14}, #{item.i15}, #{item.i16}, #{item.dataTime}, #{item.createTime})",
            "</foreach>",
            "</script>"
    })
    int insertIgnoreBatchCombinerboxDataHis(@org.apache.ibatis.annotations.Param("tableSuffix") String tableSuffix,
                                         @org.apache.ibatis.annotations.Param("list") java.util.List<ForwardCombinerBoxDataDO> list);

    /**
     * 插入组串数据
     * @param list
     * @return
     */
    @org.apache.ibatis.annotations.Insert(value = {
            "<script>",
            "INSERT IGNORE INTO solar_forward_string_data_currentday (`id`,`tenant_no`,`organ_no`,`device_pid`,`device_id`,`device_name`,`device_code`,`voltage`,`electric_current`,`data_time`,`create_time`) VALUES ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.id}, #{item.tenantNo}, #{item.organNo}, #{item.devicePid}, #{item.deviceId}, #{item.deviceName}, #{item.deviceCode}, #{item.voltage}, #{item.electricCurrent}, #{item.dataTime}, #{item.createTime})",
            "</foreach>",
            "</script>"
    })
    int insertIgnoreBatchStringDataCurrentDay(java.util.List<ForwardStringDataDO> list);

    /**
     * 插入组串历史数据
     * @param list
     * @return
     */
    @org.apache.ibatis.annotations.Insert(value = {
            "<script>",
            "INSERT IGNORE INTO solar_forward_string_data_his_${tableSuffix} (`id`,`tenant_no`,`organ_no`,`device_pid`,`device_id`,`device_name`,`device_code`,`voltage`,`electric_current`,`data_time`,`create_time`) VALUES ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.id}, #{item.tenantNo}, #{item.organNo}, #{item.devicePid}, #{item.deviceId}, #{item.deviceName}, #{item.deviceCode}, #{item.voltage}, #{item.electricCurrent}, #{item.dataTime}, #{item.createTime})",
            "</foreach>",
            "</script>"
    })
    int insertIgnoreBatchStringDataHis(@org.apache.ibatis.annotations.Param("tableSuffix") String tableSuffix,
                          @org.apache.ibatis.annotations.Param("list") java.util.List<ForwardStringDataDO> list);
}
